<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  
<html xmlns = "http://www.w3.org/1999/xhtml">
  <!-- 2012 lukbrasil -->
  <!-- Internet & World Wide Web How To Program - Exercise 7.11 -->
  <head>
    <title>Exercise 7.11</title>
    
    <script type = "text/javascript">
      <!--
      var menu;
      var mileDriven;
      var gallonUsed;
      var totalMileDriven = 0;
      var totalGallonUsed = 0;
      
      menu = parseInt(window.prompt("Enter an option (1 = input tankful, 2 = quit)", "1"));
      while (menu != 2) {
        mileDriven = parseInt(window.prompt("Enter miles driven as an integer", "0"));
        gallonUsed = parseInt(window.prompt("Enter gallons used as an integer", "0"));        
        
        if (gallonUsed != 0) {
          document.writeln("Miles per gallon is " + mileDriven / gallonUsed + "<br/>");
        }
        
        totalMileDriven += mileDriven;
        totalGallonUsed += gallonUsed;
        
        menu = parseInt(window.prompt("Enter an option (1 = input tankful, 2 = quit)", "1"));
      }
      
      if (totalGallonUsed != 0) {
        document.writeln("<h1>Total miles per gallon is " + totalMileDriven / totalGallonUsed + "</h1>");
      }      
      // -->
    </script>
  </head>
  <body>
  </body>
</html>
